home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The CICA Windows Explosion!
/
The CICA Windows Explosion! - Disc 2.iso
/
programr
/
appsrcs.zip
/
APPBAR.ZIP
/
APPCLOSE.C
< prev
next >
Wrap
C/C++ Source or Header
|
1993-03-13
|
2KB
|
67 lines
#define STRICT
#include <windows.h>
#include <windowsx.h>
#include <shellapi.h>
#include <string.h>
#include "appbar.h"
BOOL fWMCloseSeen = TRUE;
FARPROC lpfnOrgCloseWndProc;
long WINAPI WaitForWMCloseWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
LRESULT lRet;
lRet = CallWindowProc((WNDPROC)lpfnOrgCloseWndProc, hWnd, message, wParam, lParam);
if(message == WM_CLOSE)
{
if(IsWindow (hWnd))
SetWindowLong(hWnd, GWL_WNDPROC, (WPARAM) lpfnOrgCloseWndProc);
fWMCloseSeen = TRUE;
}
return lRet;
}
/*------------------------------------------------------------------------*/
VOID PASCAL WaitForWMClose(HWND hWndClose)
{
static FARPROC lpfnMy = NULL;
MSG msg;
if(lpfnMy == NULL)
{
lpfnMy = MakeProcInstance((FARPROC) WaitForWMCloseWndProc, hInst);
if (lpfnMy == NULL)
return;
}
lpfnOrgCloseWndProc = (FARPROC) GetWindowLong(hWndClose, GWL_WNDPROC);
SetWindowLong(hWndClose, GWL_WNDPROC, (WPARAM) lpfnMy);
fWMCloseSeen = FALSE;
// This is a MUST here. We need to keep messages flowing around while
// we're waiting a program to make up his mind with this close thing.
do {
if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
while(!fWMCloseSeen);
// We've just seen WM_DESTROY let the app to clean up
// himself completely before we go on.
Yield();
}
/*-------------------------------------------------------------------------*/
BOOL PASCAL CloseApp(HWND hWndClose)
{
PostMessage(hWndClose, WM_CLOSE, 0, 0L);
WaitForWMClose(hWndClose);
//if windows is still there, application refused to die.
if(IsWindow(hWndClose))
return FALSE;
return TRUE;
}